| 1 |  |  | import EventPoll from '../event_poll' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | import VotingUrl from '../voting_url' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | import App from './app' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | import EventPollRepository from '../infrastructure/in_memory/event_poll_repository' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | const baseUrl = 'http://domain.org' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | describe('a doodle like app', () => { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |   describe('create event scheduling poll', () => { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 10 |  |  |     it('returns an event poll', async () => { | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |         const anEventPoll = await createPoll() | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |         expect(anEventPoll).toBeInstanceOf(EventPoll) | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     }) | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     it('has a title and possible dates for the event', async () => { | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |       const possibleDates = [new Date(), new Date()] | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |       const aTitle = 'Event title' | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |       const anEventPoll = await createPoll(aTitle, possibleDates) | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |       expect(anEventPoll.title).toBe(aTitle) | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |       expect(anEventPoll.possibleDates).toBe(possibleDates) | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     }) | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     it('gives an URL to share with attendees to vote', async () => { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |       const anEventPoll = await createPoll() | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |       const aVotingUrl = anEventPoll.votingUrl() | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |       const expectedUrl = new VotingUrl(baseUrl, anEventPoll) | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |       expect(aVotingUrl.equalsTo(expectedUrl)).toBe(true) | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     }) | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     describe('someone visits the voting URL', () => { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |       it('allows user to confirm attendance', () => { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |       }) | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | function createPoll (aTitle, possibleDates) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |   const eventPollRepository = new EventPollRepository() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |   const app = new App(baseUrl, eventPollRepository) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |   return app.newEventPoll(aTitle, possibleDates) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     .then( (anEventPollId) => { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |       return eventPollRepository.findById(anEventPollId) | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |     }) | 
            
                                                        
            
                                    
            
            
                | 47 |  |  | } |